package com.hse.network;

import com.hse.network.exceptions.NetworkException;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

/**
 * Created by IntelliJ IDEA.
 * User: Lexa
 * Date: May 30, 2009
 * Time: 1:05:25 PM
 * To change this template use File | Settings | File Templates.
 */
public class EndDeviceTester {
    private IEndDevice endDevice;
    private final Long MAC_ADDRESS = (long) 0x10;
    private final Short PAN_ID = (short) 12345;

    @Before
    public void init() throws InstantiationException {
        endDevice = new EndDevice(TestConfigurator.PORT_NAME_1, MAC_ADDRESS);
    }

    @After
    public void delete() {
        endDevice.close();
    }

    @Test(expected = NetworkException.class)
    public void connectToNonExistingNetwork() throws NetworkException {
        endDevice.connect(PAN_ID);
    }

    @Test
    public void scanNonExistingNetworks() throws NetworkException {
        final Network[] networks = endDevice.scan();
        Assert.assertEquals(0, networks.length);
    }
}
